package online.longzipeng.mywebdemo;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.javafaker.Faker;
import lombok.extern.slf4j.Slf4j;
import online.longzipeng.mywebdemo.utils.MockUtils;
import online.longzipeng.mywebdemo.utils.MyJsonUtils;
import org.junit.jupiter.api.Test;

import javax.script.ScriptException;
import java.util.Locale;

/**
 * @Author: lzp
 * @description:
 * @Date: 2022/12/1
 */
@Slf4j
public class MockDemo {

	public static void main(String[] args) throws ScriptException, JsonProcessingException {
//		System.out.println(MockUtils.getTel());
//		System.out.println(MockUtils.name());
//		System.out.println(MockUtils.cname());
//		System.out.println(MockUtils.mockRandom("Random.url()"));
//		System.out.println(MockUtils.mock("{\n" + "  \"star|3\": \"★★★\"\n" + "}"));
		String jsonStr = "{\"head\":{\"face\":\"老王的小脸\",\"eye\":\"迷人的大眼睛\",\"iq\":250},\"body\":\"身材修长\"}";
//		String value = MyJsonUtils.getInstance().getValueByKeyPath(jsonStr, "", String.class);
		ObjectMapper objectMapper = new ObjectMapper();
		JsonNode jsonNode = objectMapper.readTree(jsonStr);
		System.out.println(jsonNode);
	}

	@Test
	public void fakerMock() {
		Faker faker = new Faker(Locale.CHINA);

		String name = faker.name().fullName(); // Miss Samanta Schmidt
		String firstName = faker.name().firstName(); // Emory
		String lastName = faker.name().lastName(); // Barton

		String streetAddress = faker.address().streetAddress(); // 60018 Sawayn Brooks Suite 449

//		log.info(name);
//		log.info(firstName);
//		log.info(lastName);
//		log.info(streetAddress);
//		log.info(faker.cat().registry());
//		log.info(faker.cat().name());
//		log.info(faker.job().title());
		for (int i = 0; i < 100; i++) {
			log.info(faker.number().digits(10));
		}
	}

}
